package medium.滑动窗口;

/**
 * 1456. 定长子串中元音的最大数目
 * 创建时间：2024-05-23 10:52
 */
public class 定长子串中元音的最大数目_1456 {
    static class Solution {
        public int maxVowels(String s, int k) {
            int right = 0, max = 0;
            byte[] vowel = new byte['z' + 1];
            vowel['a'] = vowel['e'] = vowel['i'] = vowel['o'] = vowel['u'] = 1;
            while (right < k) {
                max += vowel[s.charAt(right++)];
            }
            int left = 0, ans = max, n = s.length();
            while(right < n) {
                max += vowel[s.charAt(right++)] - vowel[s.charAt(left++)];
                ans = Math.max(ans, max);
            }
            return ans;
        }
    }

    public static void main(String[] args) {
        Solution s = new Solution();
        System.out.println(s.maxVowels("ibpbhixfiouhdljnjfflpapptrxgcomvnb", 33));
    }
}
